import Pageable from "@/utils/Pageable";
import { Request } from "@/utils/http";
import { ServerResponse } from "@/utils/serverResponse";

interface addParams {

}

interface queryParams {
    data: {
        name?: string
    },
    current: number,
    pageSize: number
}

interface listItem {

}

interface listVo extends Pageable {
    data: listItem[]
}

interface typeListItem {

}

export default class ListApi {

    // 获取收支列表
    public async queryList(params: queryParams): Promise<listVo | undefined> {
        const res: ServerResponse<listVo> = await Request.post('/api/incAndExp/list', params)
        return res.data
    }

    // 获取收支类型
    public async typeList(): Promise<typeListItem[] | undefined> {
        const res: ServerResponse<typeListItem[]> = await Request.get('/api/incAndExp/typeList')
        return res.data
    }

    // 添加
    public async add(params: addParams): Promise<any> {
        const res: ServerResponse<number> = await Request.post('/api/incAndExp/add', params)
        return res
    }

    //编辑
    public async edit(params: addParams): Promise<any> {
        const res: ServerResponse<number> = await Request.post('/api/incAndExp/edit', params)
        return res
    }

    // 删除计划
    public async delete(id: string): Promise<any> {
        const res: ServerResponse<number> = await Request.get('/api/incAndExp/delete?id=' + id)
        return res.data
    }
}